#include "mainwindow.h"
#include <QApplication>
#include "detectmask.h"
#include <iostream>
#include <string>
#include <vector>
#include "opencv2/core.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/imgproc.hpp"
#include "paddle_api.h"  // NOLINT


//int main(int argc, char** argv) {
//  if (argc < 3) {
//    std::cerr << "[ERROR] usage: " << argv[0]
//              << " detction_model_dir classification_model_dir image_path\n";
//    exit(1);
//  }

//  std::string detect_model_dir = argv[1];
//  std::string classify_model_dir = argv[2];
//  std::string img_path = argv[3];
//  std::cout << "detect_model_dir " << detect_model_dir << " classify " << classify_model_dir << " " << img_path << std::endl;
//  RunModel(detect_model_dir, classify_model_dir, img_path);
//  return 0;
//}

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
//    MainWindow w;
//    w.show();
    DetectMask detector;
    std::string detect_model_dir = "./mask_detection/face_detection";
    std::string classify_model_dir = "./mask_detection/mask_classification";
    detector.init(detect_model_dir,classify_model_dir);

    std::vector<cv::String> image_path;
    cv::glob("./face_detect_Images/*.jpg",image_path);
    for(auto it: image_path){
        std::cout << it << std::endl;
        cv::Mat frame = cv::imread(it);
        detector.detect(frame);
        cv::waitKey(0);
    }

    cv::VideoCapture cap(0);
    if(!cap.isOpened()){
        std::cout << "video capture failed" << std::endl;
        return -1;
    }
    cv::Mat frame;
    while(cap.read(frame)){
        detector.detect(frame);
        cv::waitKey(10);
    }

    return a.exec();
}
